<?php
/**
 * The SupportCase form, used for creation and edition
 * @package ModuleAssistance
 * @version 1.0b
 */
?>

<form action="" method ="post" class="form-crud">
<table cellpadding="0" cellspacing="0" border="0" class="form">
	<tr>
		<td class="form-crud-label" colspan="4"><h3 class="subtitle"><?php echo ($_GET['operation'] == 'edit') ? 'Mise à jour #'.$supportcase->supportcaseId : 'Nouvelle Mise à jour'; ?></h3></td>
	<tr>
	<tr>
		<td class="form-crud-label"><label for="update-supportcase">Ticket :</label></td>
		<td class="form-crud-input"><input id="update-supportcase" type="text" name="update-supportcase" value="<?php echo $supportcase->supportcaseId; ?>" readonly="readonly" /></td>
		<td class="form-crud-label"><label for="update-owner">Proriétaire :</label></td>
		<td class="form-crud-input"><input id="update-owner" type="text" name="update-owner" value="<?php echo $contact->lastname.' '.$contact->firstname; ?>" readonly="readonly" /></td>
	</tr>
	<tr>
		<td class="form-crud-label" colspan="4"><h3 class="subtitle">Description</h3></td>
	<tr>
	<tr>
		<td class="form-crud-input" colspan="4">
			<textarea id="update-content" rows="10" cols="10" name="update-content"><?php echo $update->content; ?></textarea>
		</td>
	</tr>
</table>
<br />
<input type="hidden" value="<?php echo $update->updateId; ?>" name="update-updateId" />
<input type="hidden" value="<?php echo $update->crmuserId; ?>" name="update-ownerId" />
<input type="hidden" value="<?php echo $_GET['operation']; ?>" name="update-operation" />
<a href="#" id="form-update" class="submit">Sauvegarder</a>

<?php if ($_GET['operation'] != 'add'): ?>
<table cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td class="form-crud-label" colspan="4"><h3 class="subtitle">Documents</h3></td>
	<tr>
	<tr>
		<td class="form-crud-label"></td>
		<td class="form-crud-input">
			<table cellpadding="0" cellspacing="0" border="0" class="documents">
			<?php
			$documentList = $update->GetDocumentList();
			foreach ($documentList as $document) {
				$res  = '<tr>';
				$res .= '<td class="del"><a href="'.$document->documentId.'" class="delete-doc"><img src="css/img/bin_empty.png" alt="Delete" /></a></td>';
				$res .= '<td><a href="'.$configuration['appdir'].'data/docs/'.$document->documentId.'.'.$document->extension.'" target="_blank" class="file">'.$document->filename.'.'.$document->extension.'</a></td>';
				$res .= '</tr>';
				echo $res;
			}
			?>
			</table>
		</td>
		<td class="form-crud-label"></td>
		<td class="form-crud-input"></td>
	</tr>
	<tr>
		<td class="form-crud-label"><label for="update-file-upload">Ajouter des fichiers :</label></td>
		<td class="form-crud-input"><input id="update-file-upload" name="update-file-upload" type="file" /></td>
		<td class="form-crud-label"></td>
		<td class="form-crud-input"></td>
	</tr>
	<tr>
		<td class="form-crud-label"></td>
		<td class="form-crud-input"><a href="javascript:$('#update-file-upload').uploadifyUpload()" class="upload">Upload</a></td>
		<td class="form-crud-label"></td>
		<td class="form-crud-input"></td>
	</tr>
</table>
<?php endif; ?>

</form>

<div id="result"></div>

<div id="select_supportcase" class="hidden"></div>